<?php

namespace app\queue\redis;

use app\common\library\Show;
use app\queue\BaseJob;
use support\Redis;

class Hello extends BaseJob
{
    // 要消费的队列名
    public $queue = 'hello';

    // 连接名，对应 plugin/webman/redis-queue/redis.php 里的连接`
    public $connection = 'webman_gii';

    public function doJob($data)
    {
        try {
            echo date('Y-m-d H:i:s').PHP_EOL;
            var_dump($data);
            echo PHP_EOL;
            Redis::setEx($data['key'], 1000, json_encode($data,true));
            return Show::success();
        } catch (\Throwable $e) {
            return Show::error($e->getMessage());
        }
    }
}